﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.events.*;
    import Transactions.*;
    import Classes.util.*;
    import Modules.stats.types.*;

    public class SimpleHarvestableResource extends HarvestableResource {

        public function SimpleHarvestableResource(_arg1:String=null){
            super(_arg1);
            m_state = STATE_PLANTED;
        }
        override public function get isWitherOn():Boolean{
            return (false);
        }
        override protected function getSellPrice():int{
            return (m_item.sellPrice);
        }
        override public function warnForStorage():Boolean{
            return (true);
        }
        override public function restoreFromStorage():void{
            setState(STATE_PLANTED);
            plantTime = GlobalEngine.serverTime;
            super.restoreFromStorage();
        }
        override public function onPlayAction():void{
            if (m_visitReplayLock > 0){
                return;
            };
            m_actionMode = PLAY_ACTION;
            super.onPlayAction();
            if (Global.isVisiting()){
                return;
            };
            if (this.isHarvestable()){
                this.startHarvest();
            };
        }
        override public function onMouseOver(_arg1:MouseEvent):void{
            super.onMouseOver(_arg1);
            updateObjectIndicator();
        }
        override public function onMouseOut():void{
            super.onMouseOut();
            updateObjectIndicator();
        }
        override protected function isObjectIndicatorVisible():Boolean{
            return (false);
        }
        override protected function updateState(_arg1:Number):Boolean{
            if (((this.isHarvestable()) && ((m_state == STATE_PLANTED)))){
                setState(STATE_GROWN);
                return (true);
            };
            return (false);
        }
        protected function startHarvest():void{
            if (this.isHarvestable()){
                if (this.harvest()){
                    this.doHarvestDropOff();
                };
            };
        }
        override public function isHarvestable():Boolean{
            return ((((getGrowPercentage() == 100)) || ((m_state == STATE_GROWN))));
        }
        override public function doHarvestDropOff(_arg1:Boolean=true):Object{
            if (_arg1){
                displayDelayedResourceChanges();
            };
            return (super.doHarvestDropOff(_arg1));
        }
        override public function harvest():Boolean{
            var _local1:Boolean;
            if (this.isHarvestable()){
                if (!Global.isVisiting()){
                    m_doobersArray = makeDoobers();
                    spawnDoobers();
                    if (m_actionMode != VISIT_REPLAY_ACTION){
                        GameTransactionManager.addTransaction(new THarvest(this));
                        trackAction(TrackedActionType.HARVEST);
                    };
                };
                setState(STATE_PLANTED);
                plantTime = GlobalEngine.getTimer();
                _local1 = true;
            };
            m_harvestCounter++;
            updateObjectIndicator();
            return (_local1);
        }
        override public function getVisitReplayEquivalentActionString():String{
            return ("harvest");
        }

    }
}//package Classes 
